import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/face'
  },
  {
    path:"/face",
    name:"face",
    component: () => import('@/views/face/face.vue'),
  },
  {
    path: '/main',
    name: 'main',
    component: () => import('@/views/main/main.vue'),
    redirect:"/main/home",
    children:[
      {
        path:"home",
        name:"home",
        component:()=>import('@/views/home/home.vue'),
      },
      {
        path:"list",
        name:"list",
        component:()=>import('@/views/list/list.vue'),
      },
      {
        path:"video",
        name:"video",
        component:()=>import('@/views/video/video.vue'),
      },
      {
        path:"mine",
        name:"mine",
        component:()=>import('@/views/mine/mine.vue'),
      },
    ]
  },
  {
    path:"/zhangjie",
    name:"zhangjie",
    component: ()=> import("@/views/zhangjie/zhangjie.vue")
  },
  {
    path:"/booknei",
    name:"booknei",
    component: ()=> import("@/views/booknei/booknei.vue")
  },
  {
    path:"/mhlist",
    name:"mhlist",
    component: ()=> import("@/views/mhlist/mhlist.vue")
  },
  {
    path:"/mhdetail",
    name:"mhdetail",
    component: ()=> import("@/views/mhlist/mhdetail.vue")
  },
  {
    path:"/search",
    name:"search",
    component: ()=> import("@/views/search/search.vue")
  },
  {
    path:"/404",
    name:"404",
    component: ()=> import("@/views/notFound/404.vue")
  },
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router
